// TopSpinObject.cpp: implementation of the TopSpinObject class.
//
//////////////////////////////////////////////////////////////////////

#include <stdio.h>
#include "Pancake.h"

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

GameObject::GameObject()
{
}

GameObject::~GameObject()
{
}




// Function name	:  
// Description	    : 
// Return type		: void 
// Argument         : int *in_state
// Argument         : int *out_State
void GameObject::ConvarteStateToDual(int in_state[SIZE],int out_DualState[SIZE])
{
	for (int i=0;i<SIZE;i++)
		out_DualState[in_state[i]] = i;
}


// Function name	: MakeMove
// Description	    : This function make move iMove on in_state and puts 
//                    the result in out_state
// Return type		: void 
// Argument         : int *in_state
// Argument         : int *out_state - will contain the result
// Argument         : int iMove
void GameObject::MakeMove(int in_state[SIZE],int out_state[SIZE],int iMove)
{

	for(int i=0;i <= iMove ; i++)
		out_state[i] = in_state[iMove - i];

	for (i = iMove+ 1 ;i <SIZE; i++)
		out_state[i] = in_state[i];

}


// Function name	: IsGoal
// Description	    : Returns True if this is the goal else false
// Return type		: bool 
// Argument         : int *inUnRotatedstate
bool GameObject::IsGoal(int *inState)
{	
	for (int i=0;i<SIZE;i++)
		if(inState[i] != i)
			return false;
	return true;
}





void GameObject::PrintArray(int arr[SIZE])
{
	printf("Array[] = ");
	for (int i=0;i<SIZE;i++)
	{
		printf("%d ",arr[i]);
	}
	printf("\n");
}